package org.eCon.maven.plugin.unixBased;
/*
 * Copyright 2001-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.eCon.maven.plugin.AbstractGWTCompilePlugin;

import java.io.File;

/**
 * User: eCon
 * Date: 04-Aug-2008
 * Time: 22:12:46
 */

public abstract class UnixBasedGWTCompilePlugin extends AbstractGWTCompilePlugin {

    protected String env_dependent_jar;


    protected String getEnvLib() {
        return env_dependent_jar;
    }

    public String createGWTCompileString() {

        /**
         * it is StringBuffer because we need to compatible with older version of java.
         */
        StringBuffer sb = new StringBuffer(200);
        sb.append(this.createJavaPath());
        sb.append(" ").append(this.jvm_param).append(" -cp ");
        sb.append(this.getClasspath());
        sb.append(" ");
        sb.append(COMPILER);
        sb.append(" ");

        this.controlAndAppend(this.gwt_logLevel, "logLevel", sb, false);
        this.controlAndAppend(this.gwt_gen, "gen", sb, true);
        this.controlAndAppend(this.gwt_relative_out, "out", sb, true);
        sb.append(" \"$@\" ");

        if (this.gwt_tree) {
            sb.append("-treeLogger");
            sb.append(" ");
        }

        this.controlAndAppend(this.gwt_style, "style", sb, false);
        this.controlAndAppend(this.gwt_module, null, sb, false);

        String cmd = sb.toString();

        log.info("JAVA_PATH: " + java_path);
        log.info("Current Dir: " + currentDir);

        return cmd;
    }


    protected abstract String getJarName();

    //protected abstract String getJVMParam();

}
